﻿namespace OP10.ViewModels
{
    public class ST12CyManagerViewModel : BindableBase
    {
        private readonly IRegionManager _regionManager;

        public ST12CyManagerViewModel(IRegionManager regionManager)
        {
            _regionManager = regionManager;     
            IsCheck01 = InductorParam_Global.aByPass[11];
            CylinderDelay.DelayTime01 = InductorParam_Global.aDelay[11];
        }
        #region 事件
        private DelegateCommand _GoBackCommand;
        public DelegateCommand GoBackCommand =>
            _GoBackCommand ?? (_GoBackCommand = new DelegateCommand(ExecuteGoBackCommand));
        void ExecuteGoBackCommand()
        {
            NavigationParameters param = new NavigationParameters();
            param.Add("StationName", "ST12");
            _regionManager.RequestNavigate(PrismManager.MainViewRegionName, AppViews.ST12View, param);
        }
        /// <summary>
        /// 气缸屏蔽
        /// </summary>
        private DelegateCommand<string> _CylinderPinBiCommand;
        public DelegateCommand<string> CylinderPinBiCommand =>
            _CylinderPinBiCommand ?? (_CylinderPinBiCommand = new DelegateCommand<string>(ExecuteCylinderPinBiCommand));
        void ExecuteCylinderPinBiCommand(string p)
        {
            switch (p)
            {
                case "产品有无检测":
                    InductorParam_Global.aByPass[11] = true;
                    break;
                default:
                    break;
            }
        }
        /// <summary>
        /// 气缸解除屏蔽
        /// </summary>
        private DelegateCommand<string> _CylinderUnPinBiCommand;
        public DelegateCommand<string> CylinderUnPinBiCommand =>
            _CylinderUnPinBiCommand ?? (_CylinderUnPinBiCommand = new DelegateCommand<string>(ExecuteCylinderUnPinBiCommand));
        void ExecuteCylinderUnPinBiCommand(string p)
        {
            switch (p)
            {
                case "产品有无检测":
                    InductorParam_Global.aByPass[11] = false;
                    break;
                default:
                    break;
            }
        }
        private DelegateCommand<string> _TextChangeCommand;
        public DelegateCommand<string> TextChangeCommand =>
            _TextChangeCommand ?? (_TextChangeCommand = new DelegateCommand<string>(ExecuteTextChangeCommand));
        void ExecuteTextChangeCommand(string p)
        {
            switch (p)
            {
                case "DelayTime01":
                    InductorParam_Global.aDelay[11] = CylinderDelay.DelayTime01;
                    break;
                default:
                    break;
            }
        }
        #endregion
        #region 属性  

        private CylinderDelayModel _cylinderDelay;
        public CylinderDelayModel CylinderDelay
        {
            get { return _cylinderDelay ?? (_cylinderDelay = new CylinderDelayModel()); }
            set { SetProperty(ref _cylinderDelay, value); }
        }
        private bool _IsCheck01;
        public bool IsCheck01
        {
            get { return _IsCheck01; }
            set { SetProperty(ref _IsCheck01, value); }
        }
        #endregion
    }
}
